package com.jerry.base.java8.lambda;

import java.util.stream.Stream;

/**
 * 类名::静态方法的方法引用
 *
 * @author Jerry
 * @since 2024/7/24 20:12
 */
public class MethodRef {

    public static void main(String[] args) {
        Stream.of(
                        new Student("张无忌", "男"),
                        new Student("周芷若", "女"),
                        new Student("宋青书", "男")
                ).filter(MethodRef::isMale)
                .forEach(MethodRef::print);
    }

    record Student(String name, String sex) {
    }

    static void print(Student stu) {
        System.out.println(stu);
    }

    static boolean isMale(Student s) {
        return s.sex().equals("男");
    }
}